COST OF LIVING IN THE UK: INSIGHTS VIA AI, DATA VISUALIZATION, AND STORYTELLING¶

By Amin Sabbagh
Student ID: 18055392
EthOS Reference Number: 64001

Intro | Linear Regression Models | Further Insight | Data Preprocessing Intro | Data Preprocessing Continuous | Data Preprocessing Insights

Imported Libraries¶

  • Pandas: Used to extract data from Excel into dataframes

  • Plotly Express: Used to create interactive data visualizations.

In [1]:
import pandas as pd
import plotly.express as px

Introduction¶

Analysis of CPI Trends in the UK¶

In the initial stages of data analysis, attention is drawn to the behavior of the Consumer Price Index (CPI) in the UK.¶


  • Key Findings:
    • The depicted line graph spans the period just before Brexit and the final months of 2023.
    • Notably, it reveals a sharp increase in the inflation rate since late 2021, peaking at 9.6% in October 2022.
    • This surge has led to the most significant decline in living standards recorded in the past 60 years.
    • Influenced by factors such as Brexit, the COVID-19 pandemic, and the Ukrainian-Russian conflict, it has propelled the cost of living to its highest point in UK history.


  • Objective: The study aims to investigate to what extent has the Cost-of-Living Crisis affected the working adults in the UK using a combination of machine learning-driven and traditional data visualization storytelling.
In [2]:
# Specify the sheet name from which to read data
file_name = "COL.xlsx"
sheet_name = 'Sheet1'

# Read data from Excel file into a DataFrame
df = pd.read_excel(file_name, sheet_name)

# Save variables
x = df['Date']
y = df['CPI']

# plot the figure
fig = px.line(df, x, y,  title='Consumer Inflation Index')
fig.update_traces(line_color='#0000ff')
fig.show()

General Insights from Cost of Living Crisis¶

Insights collected from the responses to the 'Compared to a year ago, has your cost of living changed?' pie chart further support the finding of the rise of Cost Of Living.¶

  • Key Findings:
    • A staggering 93% of adults across diverse demographic backgrounds, irrespective of age, gender, or income level, have experienced an increase in their cost of living.
    • This pervasive rise reflects a widespread economic challenge faced by individuals across the spectrum of society.
    • Only a mere 7% of respondents reported a decrease or stability in their cost of living, representing a stark minority amidst the prevailing trend of upward cost escalation.
In [3]:
# Specify the sheet name from which to read data
file_name = "Pies_intro.xlsx"
sheet_name = '1'

# Read data from Excel file into a DataFrame
df_pie_one = pd.read_excel(file_name, sheet_name)

# Define a custom color palette with different shades of blue
custom_palette = ['#0066b2', '#74BBFB']

# Show the plot
fig = px.pie(df_pie_one, names='Compared to a year ago, has your cost of living changed?', values='All Adults',
             title='Compared to a year ago, has your cost of living changed?',
             labels={'Compared to a year ago, has your cost of living changed?': 'Impact'},
             color_discrete_sequence=custom_palette)
fig.show()

The insights gathered from the Pie chart, which asked the UK population regarding their ability to cover an unexpected yet essential expense of £850, paint a revealing picture of UK working-class financial struggle.¶

  • Key Findings:
    • While 55% of the population could manage such an expense if required, a substantial 45% exhibit a negative response.
    • Among the negative responses:
      • 31% explicitly state their inability to afford it.
      • 10% express uncertainty.
      • 4% prefer not to disclose their financial situation.
    • These findings underscore the dangerous financial situation faced by a significant portion of the UK population, with nearly half potentially unable to meet an £850 expense, which could encompass critical necessities such as food, energy, or housing.
In [4]:
# Read data from Excel file into a DataFrame
sheet_name = '2'
df_pie_two = pd.read_excel(file_name, sheet_name)

custom_palette = ['#0066b2', '#74BBFB', '#89CFF0', '#F0F8FF']

# Create a pie chart using Plotly Express
fig = px.pie(df_pie_two, names='Could your household afford to pay an unexpected, but necessary, expense of £850? ', 
             values='All Adults',
             title='Could your household afford to pay an unexpected, but necessary, expense of £850?',
             labels={'Could your household afford to pay an unexpected, but necessary, expense of £850? ': 'Impact'},
             color_discrete_sequence=custom_palette)
#Explain why 850
# Show the plot
fig.show()

The insights derived from the responses to the question 'Do you think you will be able to save any money in the next 12 months?' as depicted in the Pie chart are striking.¶

  • Key Findings:
    • A significant 44% of respondents expressed a negative outlook, stating they would not be able to save any money.
    • 19% admitted uncertainty about their future saving prospects.
    • 2% opted not to disclose their response.
    • In contrast, 35% expressed optimism, affirming their ability to save.
In [5]:
# Read data from Excel file into a DataFrame
sheet_name = '3'
df_pie_three = pd.read_excel(file_name, sheet_name)

custom_palette = ['#0066b2', '#74BBFB', '#89CFF0', '#F0F8FF']

# Create a pie chart using Plotly Express
fig = px.pie(df_pie_three, names='In view of the general economic situation, do you think you will be able to save any money in the next 12 months?', 
             values='All Adults',
             title='Do you think you will be able to save any money in the next 12 months?',
             labels={'In view of the general economic situation, do you think you will be able to save any money in the next 12 months?': 'Impact'},
             color_discrete_sequence=custom_palette)

# Show the plot
fig.show()

Concerning Trends:¶

The prevalence of negative responses is concerning on multiple fronts.

Challenges Highlighted:¶

  • It underscores the challenges individuals face in affording basic essentials.
  • Lack of capacity for setting aside funds for emergencies is evident.
  • There's a broader lack of capacity for investments in assets such as property, metals, or business ventures.

Ramifications:¶

  • This shortfall in savings and investments has ramifications beyond individual financial security.
  • It can potentially hinder economic growth and innovation by limiting the availability of capital for productive ventures, resulting in a loss of potential jobs.